package comxin.demo1.jdbcdemo;

import comxin.demo1.Utils.JdbcUtils;

import java.sql.*;
/*
    对数据库，进行处理查询结果集
 */

public class jdbcdemo_03 {
    public static void main(String[] args) {
        Connection conn=null;
        PreparedStatement ps=null;
        ResultSet re=null;
        conn = JdbcUtils.getConnection();
        String sql1="select * from stu_information where stu_id=?";
        try {
            ps = conn.prepareStatement(sql1);
            ps.setInt(1,1);
            re = ps.executeQuery();
            if (re.next()!=false){
                System.out.println(re.getInt(1)+re.getString(2));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JdbcUtils.close(conn,ps,re);
        }


    }
}
